<template>
	<view class="container">
		<view class="swiper-box">
			<!-- showTitle 代标题 加这个属性 -->
			<u-swiper :list="carList" keyName="img" autoplay :height="362" indicator indicatorMode="line" circular
				:interval="5000" indicatorStyle="bottom: 40px" @change="e => current = e.current" @click="swiperJump()">
				<view slot="indicator" class="indicator">
					<view class="indicator__dot" v-for="(item, index) in carList" :key="index"
						:class="[index === current && 'indicator__dot--active']">
					</view>
				</view>
			</u-swiper>
		</view>
		<view class="nav-box">
			<view class="nav-list" @click="jump('../../promotionpages/car/list')">
				<image src="/static/images/car_nav_1.png" mode="widthFix" class="img"></image>
			</view>
			<view class="nav-list" @click="jump('../../promotionpages/car/guide')">
				<image src="/static/images/car_nav_2.png" mode="widthFix" class="img"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad() {
			this.init()
		},
		data() {
			return {
				current: 0,
				carList: [],
			}
		},
		methods: {
			init() {
				this.$func.request('/system/rotation').then(res => {
					this.carList = res.data.datas;
				})
			},
			swiperJump(e) {
				console.log(this.carList[e].sn);

			},
			jump(url) {
				uni.navigateTo({
					url: url
				})
			}


		},
	}
</script>

<style lang="scss">
	.container {
		background: #f4f8fd;
		display: flex;
		flex-direction: column;
		height: 100vh;
	}

	.img {
		width: 100%;
		vertical-align: top;
	}

	.nav-box {
		display: flex;
		justify-content: space-between;
		padding: 0 30rpx;
		box-sizing: border-box;
	}

	.nav-list {
		flex: 1;
		padding: 20rpx 10rpx;
		box-sizing: border-box;
	}

	.indicator {
		@include flex(row);
		justify-content: center;

		&__dot {
			height: 6px;
			width: 60px;
			border-radius: 100px;
			background-color: rgba(255, 255, 255, 0.35);
			margin: 0 5px;
			transition: background-color 0.3s;

			&--active {
				background: #fff;
			}
		}
	}

	.swiper-box {
		padding: 40rpx 40rpx 0;
		background: linear-gradient(180deg, #CBE2FA, #fff);
	}
</style>